package com.feri.api.util;

import com.baidu.aip.contentcensor.AipContentCensor;
import org.json.JSONObject;

/**
 * @author lr
 * @date 2022/10/3
 */
public class BaiduCensorUtil {
    //设置APPID/AK/SK
    public static final String APP_ID = "17214730";
    public static final String API_KEY = "WnrcZnQNbveI7UG7sDroOm1K";
    public static final String SECRET_KEY = "FUui3jN440l9eLN8B335C3VS62HvtafU";
    public static final AipContentCensor client;
    static {
        client = new AipContentCensor(APP_ID, API_KEY, SECRET_KEY);
    }

    /**
     * 文本审核
     * @param text 要审核的文本内容*/
    public static boolean textCensor(String text){
        JSONObject response = client.textCensorUserDefined(text);
        return response.getInt("conclusionType")==1;
    }
    /**
     * 图片审核
     * @param data 要审核图片内容*/
    public static boolean imgCensor(byte[] data){
        JSONObject response=client.imageCensorUserDefined(data,null);
        return response.getInt("conclusionType")==1;
    }


}